package xyz.jcat.webmvc.validator;

import xyz.jcat.common.util.BusinessUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Objects;

public class IdValidator implements ConstraintValidator<Id, Long> {

    @Override
    public boolean isValid(Long id, ConstraintValidatorContext constraintValidatorContext) {
        if(Objects.isNull(id)) {
            return true;
        }
        return BusinessUtils.isRealId(id);
    }

}
